package com.goodving.guli.model;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;

import com.goodving.guli.bt.profile.scale.WeightHwInfo;

/**
 * Created by john on 2015/11/24.
 */
public class DeviceSource {
    public static final int SRC_BRACELET = 0;
    public static final int SRC_SENSORHUB = 2;
    public static final int SRC_WEIGHT = 1;
    private static final String TAG = "DeviceSource";

    public static void bindBracelet(BraceletBtInfo braceletBtInfo) {
        Keeper.keepBraceletBtInfo(braceletBtInfo);
    }

    public static void bindSensorHub(C1222e c1222e) {
        Keeper.keepSensorHubInfo(c1222e);
    }

    public static void bindWeight(WeightHwInfo weightHwInfo) {
        Keeper.keepWeightHwInfo(weightHwInfo);
    }

    public static int getDeviceCount() {
//        return Config.m8876h().f4202l.f4259a.booleanValue() ? SRC_SENSORHUB : SRC_WEIGHT; TBD
        return SRC_WEIGHT;
    }

    public static boolean hasBind1S() {
        return Keeper.readBraceletBtInfo().f19635a == 4;
    }

    public static boolean hasBindBracelet() {
        BraceletBtInfo readBraceletBtInfo = Keeper.readBraceletBtInfo();
        return readBraceletBtInfo != null && BluetoothAdapter.checkBluetoothAddress(readBraceletBtInfo.f19636b);
    }

    public static boolean hasBindDevice() {
        return hasBindBracelet() || hasBindSensorHub() || hasBindWeight() ;
    }

    public static boolean hasBindDevice(Context context) {
        return hasBindBracelet() || hasBindSensorHub() || hasBindWeight();
    }

    public static boolean hasBindPeripheralDevice() {
        return hasBindBracelet() || hasBindShoesDevice();
    }

    public static boolean hasBindSensorHub() {
        C1222e readSensorHubInfo = Keeper.readSensorHubInfo();
        return readSensorHubInfo != null && readSensorHubInfo.m11354e();
    }

    public static boolean hasBindShoesDevice() {
//        return C1601b.m12700b(BraceletApp.m7879a());
        return false;
    }

    public static boolean hasBindStepDevice(Context context) {
        return hasBindBracelet() || hasBindSensorHub();
    }

    public static boolean hasBindWeight() {
        WeightHwInfo readWeightHwInfo = Keeper.readWeightHwInfo();
        return readWeightHwInfo != null && readWeightHwInfo.isValid();
    }

    public static void unbindBracelet() {
        Keeper.keepBraceletBtInfo(new BraceletBtInfo());
    }

    public static void unbindSensorHub() {
        Keeper.keepSensorHubInfo(new C1222e());
    }

    public static void unbindWeight() {
        Keeper.keepWeightHwInfo(new WeightHwInfo());
    }
}
